//
//  MainTabBarController.swift
//  appstore
//
//  Created by 王雷 on 2019/11/2.
//  Copyright © 2019 Roy. All rights reserved.
//

import UIKit

class MainTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        self.initMainTabBarController()
        // Do any additional setup after loading the view.
    }
    
    func initMainTabBarController() -> Void {
        
        // 今日
        let todaySB = UIStoryboard(name: "Today", bundle: Bundle.main)
        let todayNav = UINavigationController(rootViewController: todaySB.instantiateViewController(identifier: "TodayController"))
        todayNav.tabBarItem = UITabBarItem(title: "Today", image: UIImage(named: "tabbar_today"), tag: 0)
        
        // 游戏
        let gameSB = UIStoryboard(name: "Game", bundle: Bundle.main)
        let gameNav = UINavigationController(rootViewController: gameSB.instantiateViewController(identifier: "GameController"))
        gameNav.tabBarItem = UITabBarItem(title: "Game", image: UIImage(named: "tabbar_games"), tag: 1)
        
        // 更新
        let updateSB = UIStoryboard(name: "Update", bundle: Bundle.main)
        let updateNav = UINavigationController(rootViewController: updateSB.instantiateViewController(identifier: "UpdateController"))
        updateNav.tabBarItem = UITabBarItem(title: "Update", image: UIImage(named: "tabbar_updates"), tag: 2)
                
        // 查找
        let searchSB = UIStoryboard(name: "Search", bundle: Bundle.main)
        let searchNav = UINavigationController(rootViewController: searchSB.instantiateViewController(identifier: "SearchController"))
        searchNav.tabBarItem = UITabBarItem(title: "Search", image: UIImage(named: "tabbar_search"), tag: 3)
        
        self.viewControllers = [todayNav,gameNav,updateNav,searchNav]
        
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}
